import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User:xieChao
 * Date:2022/10/25 15:12
 */
public class Test {


    /**
     * 字符串中唯一的字符
     * @param s
     * @return
     */


    public static int firstUniqChar(String s) {
        if(s == null) return -1;
        int[] arr = new int[26];
        for(int i = 0;i<s.length();i++){
            char ch = s.charAt(i);
            arr[ch-97]++;
        }
        for(int i = 0;i<s.length();i++){
            char ch = s.charAt(i);
            if(arr[ch-97] == 1){
                return i;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        String s = "leetcode";
//        firstUniqChar(s);
        System.out.println(firstUniqChar(s));
    }
}
